import {dateFormat} from '../utils/utils';
import md5 from 'md5';
export function signJD(appKey,secretKey,method,rest) {
  const args = {
    // access_token:'',
    timestamp:dateFormat(new Date()),
    v: '1.0',
    sign_method: 'md5',
    format: 'json',
    app_key: appKey,
    param_json: JSON.stringify(rest),
    method
  };

  var sorted = Object.keys(args).sort();
  var basestring = secretKey;
  for (var i = 0, l = sorted.length; i < l; i++) {
    var k = sorted[i];
    basestring += k + args[k];
  }

  basestring +=secretKey;
  args.sign = md5(basestring).toUpperCase()
  // args.param_json =rest
  return args
}
